{% extends 'myadmin/base.html' %}

{% block main_body %}
<div style="height:60px">

</div>
 <div class="card-header">
     <h3 class="card-title"><a href="{% url 'myadmin_index' %}">首页</a> >> <a href="{% url 'myadmin_image_index' %}">镜像管理</a> >> 镜像添加</h3>
 </div>
<div style="width:70%; margin-left:15%;">
 <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">镜像添加</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form action="{% url 'myadmin_image_insert' %}" method="post" enctype="multipart/form-data">
                  {% csrf_token %}
                <div class="card-body">
                  <div class="form-group">
                      <label for="imagename">镜像名称<font color="red">*</font></label>
                    <input type="text" class="form-control" id="imagename" name="imagename" placeholder="请输入镜像名称">
                  </div>
                  <div class="form-group">
                    <label for="imagediskformat">镜像格式<font color="red">*</font></label>
                      <select name="imagediskformat" id="imagediskformat" class="form-control">
                         <option selected="selected" value="-1">请选择镜像格式</option>
                         <option value="qcow2">QCOW2 - QEMU模拟器</option>
                          <option value="bare">原始</option>
                          <option value="iso">ISO - 光盘镜像</option>
                          <option value="vdi">VDI - 虚拟磁盘镜像</option>
                          <option value="vhd">VHD - 虚拟硬盘</option>
                          <option value="vmdk">VMDK - 虚拟机磁盘</option>
                           <option value="docker">Docker</option>
                      </select>
                  </div>
                    <div class="form-group">
                    <label for="imagefile">镜像文件<font color="red">*</font></label>
                    <input type="file" class="form-control" id="imagefile" name="imagefile"  placeholder="请上传镜像文件">
                  </div>

                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary" onclick="return check();">提交</button>
                    &nbsp; &nbsp;
                    <button type="reset" class="btn btn-primary">重置</button>
                </div>
              </form>
            </div>
</div>
<script>
    function check(){
         imagename = document.getElementById('imagename').value;
         imagediskformat = document.getElementById('imagediskformat').value;
         imagefile = document.getElementById('imagefile').value;

         info="";

         if(imagename==""){
            info="镜像名称不能为空！！\n"
         }
         if(imagediskformat=="-1"){
            info=info+"请选择镜像格式！！\n"
         }
         if(imagefile==""){
            info=info+"请上传镜像文件！！\n"
         }
         if(info!=""){
            alert(info);
            return false;
         }

         return true;

    }
</script>

{% endblock %}